//科技庄园 多重背包
#include <iostream>
using namespace std;
const int MAXN=100;
const int MAXT=100;
int n,m,t,a;
int tao[MAXN+1][MAXN+1],cishu[MAXN+1][MAXN+1],juli[MAXN+1][MAXN+1];
int maxtao[MAXT+1];
int main()
{
    cin>>n>>m>>t>>a;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++) cin>>tao[i][j];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++) cin>>cishu[i][j];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++) juli[i][j]=2*(i+j);
    
    t=min(t,a-1);//时间和体力可以合成一维,这里注意体力不能为0
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++) 
            if (tao[i][j]>0){
                for(int t1=t;t1>=juli[i][j]*1;t1--)
                    for(int k=1;k<=min(cishu[i][j],t1/juli[i][j]);k++)
                        if (maxtao[t1]<maxtao[t1-k*juli[i][j]]+k*tao[i][j])
                                maxtao[t1]=maxtao[t1-k*juli[i][j]]+k*tao[i][j];
            }
    cout<<maxtao[t];     
}
